  <template>
  <div>
    <transition :name="transition">
      <keep-alive>
        <router-view class="view" :include="keepAlive"></router-view>
      </keep-alive>
    </transition>
    <transition name="fade">
      <div v-if="transitionName === 'slide-left'"></div>
    </transition>
  </div>
</template>
<script>
export default {
  name: "App",
  data() {
    return {
      transitionName: "",
    };
  },
  computed: {
    keepAlive () {
      console.log(this.$route.meta.keepAlive)
      return this.$route.meta.keepAlive
    }
  },
  watch: {
    $route(to, from) {
      if (to.meta.index > from.meta.index) {
        this.transition = "slide-left";
      } else {
        this.transition = "slide-right";
      }
    },
  },
};
</script>
<style lang="less" scoped>
.view {
  position: fixed;
  width: 100%;
  top: 0;
  left: 0;
  bottom: 0;
  width: 100%;
  overflow-x: hidden;
  overflow-y: scroll;
  -webkit-overflow-scrolling: touch;
  background: #ffffff;
  z-index: 100;
}
.slide-right-enter-active,
.slide-right-leave-active,
.slide-left-enter-active,
.slide-left-leave-active {
  will-change: transform;
  transition: all 500ms;
  position: absolute;
  width: 100%;
  height: 100%;
}
.slide-right-enter {
  // opacity: 0;
  transform: translate3d(0, 0, 0);
}
.slide-right-leave-active {
  // opacity: 0;
  transform: translate3d(100%, 0, 0);
}
.slide-left-enter {
  // opacity: 0;
  transform: translate3d(100%, 0, 0);
}
.slide-left-leave-active {
  // opacity: 0;
  transform: translate3d(0, 0, 0);
}

.content-enter-active,
.content-leave-active,
.content-enter-active,
.content-leave-active {
  transition: all 500ms;
}

.fade-enter,
.fade-leave-to {
  opacity: 0;
}
.fade-leave-active,
.fade-enter-active {
  transition: opacity 0.5s;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  z-index: 99;
}
</style>